package com.cindata

import com.cindata.dictionary.ContactRiskWarningDispositionType

class ContactRiskWarningDisposition
{
    String status
    ContactRiskWarningDispositionType type

	String description
	String disposalOpinions

	Date startDate
    Date endDate
    Date disposalDate

    Date createdDate = new Date()
    Date modifiedDate = new Date()
    User createBy
    User modifyBy

    static belongsTo = [contact: Contact]
    static hasMany = [attachments: Attachment]

    static mapping = {
        autowire true
    }

    static constraints = 
    {
        startDate nullable: true, blank: true
        endDate nullable: true, blank: true
        disposalDate nullable: true, blank: true

        status maxSize: 10, nullable: true, blank: true
        status inList: ['处置中', '已处置']
        description maxSize: 200, nullable: true, blank: true
        disposalOpinions maxSize: 200, nullable: true, blank: true
        modifyBy nullable: true, blank: true
        createBy nullable: true, blank: true
    }

    def springSecurityService
    def beforeInsert()
    {
        def username = springSecurityService?.getPrincipal()?.username
        createBy = User.findByUsername(username)
    }

    def beforeUpdate()
    {
        modifiedDate = new Date()
        def username = springSecurityService?.getPrincipal()?.username
        modifyBy = User.findByUsername(username)
    }
}